package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.SoulQuestions;
import com.tanhua.dubbo.api.SoulQuestionsApi;
import com.tanhua.dubbo.mapper.SoulQuestionsMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import javax.management.Query;
import java.util.List;

@Service
public class SoulQuestionsApiImpl implements SoulQuestionsApi {

    @Autowired
    private SoulQuestionsMapper soulQuestionsMapper;
    /**
     * 根据level查找对应的题目
     * @param level
     * @return
     */
    @Override
    public List<SoulQuestions> findSoulQuestionList(String level) {
        QueryWrapper<SoulQuestions> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("level",level);

        List<SoulQuestions> list = soulQuestionsMapper.selectList(queryWrapper);
        return list;
    }


    @Override
    public String getLevel(String questionId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("question_id",questionId);
        String level = soulQuestionsMapper.selectOne(queryWrapper).getLevel();
        return level;
    }
}
